<?php

namespace app\common\models;


use app\common\caches\DiaryLabelCache;
use app\common\traits\BaseModelOptionTrait;
use think\Model;
use think\model\concern\SoftDelete;

class LoveDiaryLabel extends Model
{
    use BaseModelOptionTrait, SoftDelete;

    protected $table = 'xiangji_love_diary_labels';

    protected $autoWriteTimestamp = true;

    protected $defaultSoftDelete = 0;

    protected $deleteTime = 'delete_time';

    public static function onAfterInsert(Model $model)
    {
        DiaryLabelCache::removeQueryData($model->user_id);
    }

    public static function onAfterUpdate(Model $model)
    {
        DiaryLabelCache::removeQueryData($model->user_id);
    }

    public static function onAfterDelete(Model $model)
    {
        DiaryLabelCache::removeQueryData($model->user_id);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

}
